<!DOCTYPE HTML>
<html lang="zh-hans" >
    <!-- Start book Python基础 -->
<!-- Start book Python基础 -->
    <head>
        <!-- head:start -->
<!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>文档注释 | Python基础</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        <meta name="author" content="姜伟">
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-prism/prism.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="./chapter06.html" />
    
    
    <link rel="prev" href="./chapter04.html" />
    

        <!-- head:end -->
<!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
<!-- body:start -->
        
    <div class="book"
        data-level="5"
        data-chapter-title="文档注释"
        data-filepath="chapter05.md"
        data-basepath="."
        data-revision="Sun Feb 09 2020 13:02:11 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        学习目标
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="chapter01.html">
            
                
                    <a href="./chapter01.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        什么是函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="chapter02.html">
            
                
                    <a href="./chapter02.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        函数的基本使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="chapter03.html">
            
                
                    <a href="./chapter03.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        函数的参数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4" data-path="chapter04.html">
            
                
                    <a href="./chapter04.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        函数的返回值
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="5" data-path="chapter05.html">
            
                
                    <a href="./chapter05.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        文档注释
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6" data-path="chapter06.html">
            
                
                    <a href="./chapter06.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        函数练习
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7" data-path="chapter07.html">
            
                
                    <a href="./chapter07.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        函数调用函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8" data-path="chapter08/index.html">
            
                
                    <a href="./chapter08/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        函数高级
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="chapter08/section01.html">
            
                
                    <a href="./chapter08/section01.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        局部变量和全局变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="chapter08/section02.html">
            
                
                    <a href="./chapter08/section02.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        函数返回值详解
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="chapter08/section03.html">
            
                
                    <a href="./chapter08/section03.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        函数参数详解
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="chapter08/section04.html">
            
                
                    <a href="./chapter08/section04.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        可变数据类型和不可变数据类型
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本书使用 GitBook 发布
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >Python基础</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h2 id="&#x51FD;&#x6570;&#x7684;&#x6587;&#x6863;&#x8BF4;&#x660E;">&#x51FD;&#x6570;&#x7684;&#x6587;&#x6863;&#x8BF4;&#x660E;</h2>
<h3 id="1&#x57FA;&#x672C;&#x4F7F;&#x7528;">1.&#x57FA;&#x672C;&#x4F7F;&#x7528;</h3>
<pre><code class="lang-python"><span class="hljs-prompt">&gt;&gt;&gt; </span><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">test</span><span class="hljs-params">(a,b)</span>:</span>
<span class="hljs-prompt">... </span>    <span class="hljs-string">&quot;&#x7528;&#x6765;&#x5B8C;&#x6210;&#x5BF9;2&#x4E2A;&#x6570;&#x6C42;&#x548C;&quot;</span>  <span class="hljs-comment"># &#x51FD;&#x6570;&#x7B2C;&#x4E00;&#x884C;&#x5199;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4F5C;&#x4E3A;&#x51FD;&#x6570;&#x6587;&#x6863;</span>
<span class="hljs-prompt">... </span>    print(<span class="hljs-string">&quot;%d&quot;</span>%(a+b))
<span class="hljs-prompt">... </span>
<span class="hljs-prompt">&gt;&gt;&gt; </span>
<span class="hljs-prompt">&gt;&gt;&gt; </span>test(<span class="hljs-number">11</span>,<span class="hljs-number">22</span>)  <span class="hljs-comment"># &#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x6B63;&#x5E38;&#x8C03;&#x7528;</span>
<span class="hljs-number">33</span>
&gt;&gt;&gt;
<span class="hljs-prompt">&gt;&gt;&gt; </span>help(test)  <span class="hljs-comment"># &#x4F7F;&#x7528; help &#x67E5;&#x770B;test&#x51FD;&#x6570;&#x7684;&#x6587;&#x6863;&#x8BF4;&#x660E;</span>
Help on function test <span class="hljs-keyword">in</span> module __main__:

test(a, b)
    &#x7528;&#x6765;&#x5B8C;&#x6210;&#x5BF9;<span class="hljs-number">2</span>&#x4E2A;&#x6570;&#x6C42;&#x548C;
</code></pre>
<p>&#x4F7F;&#x7528;&#x6548;&#x679C;</p>
<p><img src="imgs/&#x51FD;&#x6570;&#x8BF4;&#x660E;.png" alt="img"></p>
<h3 id="2&#x9AD8;&#x7EA7;&#x4F7F;&#x7528;">2.&#x9AD8;&#x7EA7;&#x4F7F;&#x7528;</h3>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_info</span><span class="hljs-params">(name: str, age: int)</span>:</span>
    <span class="hljs-string">&quot;&quot;&quot;
    &#x63A5;&#x6536;&#x7528;&#x6237;&#x7684;&#x540D;&#x5B57;&#x548C;&#x5E74;&#x9F84;&#xFF0C;&#x62FC;&#x63A5;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x5E76;&#x8FD4;&#x56DE;

    :param name: &#x63A5;&#x6536;&#x4E00;&#x4E2A;&#x540D;&#x5B57;
    :param age: &#x63A5;&#x6536;&#x7528;&#x6237;&#x7684;&#x5E74;&#x9F84;&#xFF0C;&#x5FC5;&#x987B;&#x662F; 0-200 &#x95F4;&#x7684;&#x4E00;&#x4E2A;&#x6574;&#x6570;
    :return: &#x8FD4;&#x56DE;&#x62FC;&#x63A5;&#x597D;&#x7684;&#x5B57;&#x7B26;&#x4E32;
    &quot;&quot;&quot;</span>
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;&#x6211;&#x7684;&#x540D;&#x5B57;&#x53EB; %s&#xFF0C;&#x4ECA;&#x5E74;&#x662F; %d &#x5C81;&quot;</span> % (name, age)


get_info(<span class="hljs-string">&quot;&#x5434;&#x5F66;&#x7956;&quot;</span>, <span class="hljs-number">19</span>)
get_info(<span class="hljs-number">520</span>, <span class="hljs-number">19</span>)  <span class="hljs-comment"># &#x6CE8;&#x610F;&#xFF0C;&#x5F62;&#x53C2;&#x4E0A;&#x6807;&#x6CE8;&#x7684;&#x7C7B;&#x578B;&#x53EA;&#x662F;&#x63D0;&#x9AD8;&#x4EE3;&#x7801;&#x7684;&#x53EF;&#x8BFB;&#x6027;&#xFF0C;&#x5E76;&#x4E0D;&#x4F1A;&#x9650;&#x5236;&#x5B9E;&#x53C2;&#x7684;&#x7C7B;&#x578B;</span>
help(get_info)
</code></pre>
<p>&#x4F7F;&#x7528;&#x6548;&#x679C;</p>
<p><img src="imgs/&#x53C2;&#x6570;&#x8BF4;&#x660E;.png" alt="img"></p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="./chapter04.html" class="navigation navigation-prev " aria-label="Previous page: 函数的返回值"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="./chapter06.html" class="navigation navigation-next " aria-label="Next page: 函数练习"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-copy-code-button/toggle.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"prism":{},"splitter":{},"copy-code-button":{},"toggle-chapters":{},"highlight":{},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
<!-- body:end -->
    </body>
    <!-- End of book Python基础 -->
<!-- End of book Python基础 -->
</html>
